package org.base23.video.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.base23.video.domain.entity.AiGuidanceConversationEntity;

import java.time.LocalDateTime;
import java.util.List;

/**
 * AI指导对话会话 Mapper
 */
@Mapper
public interface AiGuidanceConversationMapper extends BaseMapper<AiGuidanceConversationEntity> {

    /**
     * 根据用户ID分页查询对话
     */
    IPage<AiGuidanceConversationEntity> selectPageByUserId(
            Page<AiGuidanceConversationEntity> page, 
            @Param("userId") String userId,
            @Param("status") String status
    );

    /**
     * 根据用户ID和运动类型查询对话
     */
    List<AiGuidanceConversationEntity> selectByUserIdAndSportType(
            @Param("userId") String userId,
            @Param("sportType") String sportType,
            @Param("status") String status
    );

    /**
     * 查询过期的对话
     */
    List<AiGuidanceConversationEntity> selectExpiredConversations(
            @Param("expireTime") LocalDateTime expireTime
    );

    /**
     * 更新消息数量
     */
    int updateMessageCount(@Param("conversationId") String conversationId, @Param("count") Integer count);

    /**
     * 批量删除过期对话
     */
    int deleteExpiredConversations(@Param("expireTime") LocalDateTime expireTime);
} 